Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

337
Visualizações
docker run command ends up in : nginx: [emerg] unknown directive “events” in /etc/nginx/nginx.conf:1

I have installed nginx-extras from Ubuntu bash shell in my desktop Windows 10 O.S. The is required to spin up a docker container for an ASP.NET Core 3.1 Blazor web assembly application for serving the static web pages. My nginx.conf:

 events { }
   http {
      include mime.types;
      types {
         application/wasm wasm;
       }
     server {
        listen 80;
        index index.html;
        location / {
           root /var/www/web;
           try_files $uri $uri/ /index.html =404;
        }
     }
}

Dockerfile:

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
WORKDIR /app
COPY . ./
RUN dotnet publish -c Release -o output

FROM nginx:alpine
WORKDIR /var/www/web
COPY --from=build-env /app/output/wwwroot .
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80

My build command was successful.

However when I wanted to create a container using the command: docker run -p 8080:80 docker-wasm-blazor It gave me an error:

[emerg] 1#1: unknown directive "events" in /etc/nginx/nginx.conf:1 nginx: [emerg] unknown directive "events" in /etc/nginx/nginx.conf:1

I am very new to nginx and containerisation, so any help will be highly appreciated. Thanks.

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

I had the same error. Fixed by changing the encoding of the nginx.conf file. If you create the nginx.conf file in/with visual studio (Add -> new File) it's most likely that your will get the wrong encoding (other people got the same error).

In my case the encoding was UTF-8 and I needed us-ascii encoding. The easiest was to delete my nginx.conf file and recreate it outside of visual studio (I used Sublime text but I think you can use notepad).

over 4 years ago · Santiago Trujillo Relatório

0

I sorted out the issue by excluding the custom nginx.conf file to copy over the default nginx.conf file by removing the last line from the dockerfile. Now my dockerfile looks like this: FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env WORKDIR /app COPY . ./ RUN dotnet publish -c Release -o output

FROM nginx WORKDIR /usr/share/nginx/html COPY --from=build-env /app/output/wwwroot/ .

over 4 years ago · Santiago Trujillo Relatório

0

I got the same issue and fixed it by removing the white spaces from before and after "events" and "http", so my config file become:

events{}
http{
    include mime.types;
types {
    application/wasm wasm;
}

server {
    listen 80;

    # Here, we set the location for Nginx to serve the files
    # by looking for index.html
    location / {
        root /usr/local/webapp/nginx/html;
        try_files $uri $uri/ /index.html =404;
    }
}
}
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda